package com.shzu.jwc.ty.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shzu.jwc.ty.bean.InvigilatorInfo;
import com.shzu.jwc.ty.bean.InvigilatorInfoExample;
import com.shzu.jwc.ty.dao.InvigilatorInfoMapper;

@Service
public class InvigilatorInfoservice {

	@Autowired
	InvigilatorInfoMapper mapper;
	
	public Integer insert(InvigilatorInfo invigilatorInfo)
	{
		InvigilatorInfoExample invigilatorInfoExample=new InvigilatorInfoExample();
		InvigilatorInfoExample.Criteria criteria=invigilatorInfoExample.createCriteria();
		criteria.andUserTeacherInfoIdEqualTo(invigilatorInfo.getUserTeacherInfoId());
		criteria.andExamIdEqualTo(invigilatorInfo.getExamId());
		criteria.andExamTypeEqualTo(invigilatorInfo.getExamType());
		if(mapper.countByExample(invigilatorInfoExample)>0)
			return -1;
		else {
			mapper.insert(invigilatorInfo);
			return invigilatorInfo.getInvigilatorInfoId();
		}
	}
	
	public InvigilatorInfo selectone(Integer id)
	{
		return mapper.selectByPrimaryKey(id);
	}
	
	public List<InvigilatorInfo> selectbyempleid(Integer examId,String examType)
	{
		InvigilatorInfoExample invigilatorInfoExample=new InvigilatorInfoExample();
		InvigilatorInfoExample.Criteria criteria=invigilatorInfoExample.createCriteria();
		criteria.andExamIdEqualTo(examId);
		criteria.andExamTypeEqualTo(examType);
		return mapper.selectByExample(invigilatorInfoExample);
	}
	
	public Integer delete(Integer invigilatorInfoId)
	{
		return mapper.deleteByPrimaryKey(invigilatorInfoId);
	}
}
